//
//  NSObject+LXProperty.m
//  LXModelExtensionExample
//
//  Created by imera on 16/5/19.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "NSObject+LXProperty.h"
#import "LXProperty.h"

@implementation NSObject (LXProperty)

#pragma mark -  获取类的所有属性
- (NSArray *)getClassProperty
{
    NSMutableArray *arr = [[NSMutableArray alloc]init];
    uint count;
    objc_property_t *propertys = class_copyPropertyList([self class], &count);
    for (int i=0; i<count; i++) {
        objc_property_t property = propertys[i];
        LXProperty *propertyOC = [LXProperty initWithProperty:property];
        [arr addObject:propertyOC];
    }
    return arr;
}

#pragma mark -  获取类的所有成员变量
- (NSArray *)getClassIvars
{
    NSMutableArray *arr = [[NSMutableArray alloc]init];
    uint count;
    Ivar *ivars = class_copyIvarList([self class], &count);
    for (int i=0; i<count; i++) {
        Ivar ivar = ivars[i];
        const char *name = ivar_getName(ivar);
        [arr addObject:[NSString stringWithUTF8String:name]];
    }
    return arr;
}

@end
